[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
for                          for Statement

    form 1:

          for ( expr_list1 ; expr_list2 ; expr_list3 ) statement

    the following sequence of operations are performed for this form of the
    for statement:

    1. The expressions in expr_list1 are evaluated,
    2. The expressions in expr_list2 are evaluated,
    3.  If  the  resultant  value  of  expr_list2  is nonzero or a non-null
        string,  statement  is  executed.  statement  may  be  a   compound
        statement.
    4. If the resultant value of  expr_list2 is zero or a null  string, the
        'for' loop is terminated.
    5. The expressions in expr_list3 are executed.
    6. Control returns to item 2 above.


    form 2:

    for ( variable in A ) statement

    or

    for ( variable in A[s_expr_list]...[s_expr_list] ) statement

    For  each  subscript  in  the  next  higher  index  level  in the array
    reference,  variable  is  set  to  the  index  value  and  statement is
    executed.     Statement  may   be  a   compound  statement.     For   a
    multidimensional  array,  the  second   form  may  be  used   to  loop
    sequentially through the indices of the next higher index level.   Thus
    for a two dimensional array:

    for ( i in A )
      for ( j in A[i] )

    will loop through the indices in the array in row order.

See Also: break return while do
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson